from django.db import models


# Create your models here.
# 保存集群信息，可通过django后台管理
class ClusterInfo(models.Model):
    cluster_name = models.CharField(max_length=100, unique=True, verbose_name="集群名称")
    cluster_address = models.CharField(max_length=200, unique=True, verbose_name="集群地址")
    add_time = models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table = "cluster_info"
        verbose_name_plural = verbose_name = "集群信息"

    def __str__(self):
        return self.cluster_name


# 保存kubeconfig文件
class KubeConfig(models.Model):
    choice = [
        ("1", "token"),
        ("2", "kubeconfig")
    ]
    auth_type = models.CharField(max_length=20, choices=choice, default="2", verbose_name="认证类型")
    cus_token = models.CharField(max_length=50, verbose_name="自定义token")
    config_text = models.TextField(verbose_name="kubeconfig文件信息")
    add_time = models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table = "kubeconfig_info"
        verbose_name_plural = verbose_name = "kubeconfig信息"

    def __str__(self):
        return self.cus_token
